/*
 * Copyright (C) Jochen Hiller, Bernd Kolb.
 * 
 * Licensed under Apache 2.0.
 * See http://www.apache.org/licenses/LICENSE-2.0
 */
package demo.hello.android;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class HelloAndroidActivity extends Activity {

	private static final int DIALOG_ABOUT = 1;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		Button aboutButton = (Button) findViewById(R.id.about);
		aboutButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Log.e("hello", "about button clicked");
				showDialog(DIALOG_ABOUT);
			}
		});
	}

	/** Called when an dialog will be requested. */
	@Override
	protected Dialog onCreateDialog(int id) {
		switch (id) {
		case DIALOG_ABOUT:
			return new AlertDialog.Builder(this).setTitle(
					R.string.about_dialog_title).setMessage(
					R.string.about_dialog_message).setCancelable(false)
					.setPositiveButton(R.string.about_dialog_ok_button,
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int whichButton) {
									/* User clicked OK so do some stuff */
									Log.e("hello", "about dialog closed");
								}
							}).create();
		}
		return null;
	}
}